//
//  UILabel+Size.m
//  MeetCard
//
//  Created by longmin on 16/11/25.
//  Copyright © 2016年 timtian. All rights reserved.
//

#import "UILabel+Size.h"

@implementation UILabel (Size)

-(CGSize)lm_sizeWithMargin:(CGFloat)margin {
    return [self.text boundingRectWithSize:CGSizeMake(__kScreenWidth - margin * 2, CGFLOAT_MAX)
                                         options:NSStringDrawingUsesLineFragmentOrigin
                                      attributes:@{NSFontAttributeName : self.font}
                                         context:nil].size;
}


// 调整行间距
-(NSAttributedString *)getAttributedStringWithString:(NSString *)string lineSpace:(CGFloat)lineSpace {
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing = lineSpace; // 调整行间距
    NSRange range = NSMakeRange(0, [string length]);
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];
    return attributedString;
}




@end
